package com.zhanqiao.controller;

import com.google.gson.Gson;
import com.zhanqiao.service.DeleteDraftService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@WebServlet("/deletearticle")
public class DeleteDraftController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String deleteId = req.getParameter("id");
        DeleteDraftService deleteDraftService = new DeleteDraftService();
        int i = deleteDraftService.articleService(deleteId);
        Map message = new HashMap();
        message.put("msg",i);
        String result = new Gson().toJson(message);
        resp.getWriter().write(result);

    }
}

